<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
  <th:block th:include="include :: header('新增库存')"/>
  <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
  <form id="form-stock-add" class="form-horizontal">
    <input name="deptId" type="hidden" id="treeId"/>
    <h4 class="form-header h4">新增库存</h4>
    <div class="row">
      <div class="col-sm-6">
        <div class="form-group">
          <label class="col-sm-4 control-label is-required">货位编号：</label>
          <div class="col-sm-8">
            <input name="cargoSpaceName" id="cargoSpaceName" placeholder="请输入货位编号" style="width: 90%;float: left" autocomplete="off" class="form-control" type="text" maxlength="30"
                   required>

            <input name="cargoSpaceId" id="cargoSpaceId" placeholder="请输入货位编号"  style="display: none">
            <a id="selectCargoSpace" class="btn btn-success" onclick="selectCargoSpace()"style="float: right" >
              ...
            </a>
          </div>
        </div>
      </div>
      <div class="col-sm-6">
        <div class="form-group">
          <label class="col-sm-4 control-label is-required">库存状态：</label>
          <div class="col-sm-8">
            <select name="stockStatus" class="form-control"  id="stockStatus" maxlength="30">
              <option value="0" selected="true">正常</option>
              <option value="1">冻结</option>
            </select>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-sm-6">
        <div class="form-group">
          <label class="col-sm-4 control-label is-required">物料编号：</label>
          <div class="col-sm-8">
            <input name="productName" id="productName" placeholder="请输入物料编号"style="width: 90%;float: left"  class="form-control"autocomplete="off" type="text" maxlength="30"
                   required>
            <input name="productId" id="productId" placeholder="请输入物料编号" style="display: none">
            <a id="selectProductId" class="btn btn-success" onclick="selectProductId()" style="float: right" >
              ...
            </a>
          </div>
        </div>
      </div>
      <div class="col-sm-6">
        <div class="form-group">
          <label class="col-sm-4 control-label is-required">物资状态：</label>
          <div class="col-sm-8">
            <select name="productStatus" class="form-control"  id="productStatus" maxlength="30">
              <option value="1" selected="true">待检品</option>
              <option value="2">合格品</option>
              <option value="3">不合格品</option>
            </select>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-sm-6">
        <div class="form-group">
          <label class="col-sm-4 control-label is-required">托盘条码：</label>
          <div class="col-sm-8">
            <input name="trayCode" placeholder="请输入托盘条码" class="form-control"autocomplete="off" type="text" maxlength="30"
                   required>
          </div>
        </div>
      </div>
      <div class="col-sm-6">
        <div class="form-group">
          <label class="col-sm-4 control-label is-required">批号：</label>
          <div class="col-sm-8">
            <input name="lotNo" placeholder="请输入批号" autocomplete="off" class="form-control" type="text" maxlength="30"
                   required>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-sm-6">
        <div class="form-group">
          <label class="col-sm-4 control-label is-required">数量：</label>
          <div class="col-sm-8">
            <input name="quantity" placeholder="请输入数量" autocomplete="off" class="form-control" type="text" maxlength="30"
                   required>
          </div>
        </div>
      </div>
      <div class="col-sm-6">
        <div class="form-group">
          <label class="col-sm-4 control-label is-required">入库类型：</label>
          <div class="col-sm-8">
            <select name="inType" class="form-control"  id="in_type" maxlength="30">
              <option value="1" selected="true">WMS建单入库</option>
              <option value="2">ERP入库</option>
            </select>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-sm-6">
        <div class="form-group">
          <label class="col-sm-4 control-label is-required">入库班组编号：</label>
          <div class="col-sm-8">
            <input name="inClassId" placeholder="请输入入库班组编号" autocomplete="off" class="form-control" type="text" maxlength="30"
                   required>
          </div>
        </div>
      </div>
      <div class="col-sm-6">
        <div class="form-group">
          <label class="col-sm-4 control-label is-required">仓库名称：</label>
          <div class="col-sm-8">
            <select name="warehouseId" class="form-control"  id="warehouseId" maxlength="30">
              <option value="01" selected="true">立体库</option>
              <option value="02" selected="true">平库</option>
            </select>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-sm-6">
        <div class="form-group">
          <label class="col-sm-4 control-label is-required">车间班组号：</label>
          <div class="col-sm-8">
            <input name="classgroupNumber" placeholder="请输入车间班组编号" autocomplete="off" class="form-control" type="text" maxlength="30"
                   required>
          </div>
        </div>
      </div>
    </div>
  </form>
</div>

<div class="row">
  <div class="col-sm-offset-5 col-sm-10">
    <button type="button" class="btn btn-sm btn-primary" onclick="submitStock()"><i class="fa fa-check"></i>保 存
    </button>&nbsp;
    <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
    </button>
  </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script>
  var prefix = ctx + "stock/stockCheck";
  var ItemCodeInfoDlg = {
    data: {
      deptId: ""
    }
  };

  //项目保存
  function submitStock() {
    var password = $("#password").val();
    if (true) {
      var data = $("#form-stock-add").serializeArray();
      $.operate.saveTab(prefix + "/add", data);
    }
  }

  // 选择货位
  function selectCargoSpace() {
    var options = {
      title: '选择货位',
      url : "/device/basCargoSpace/selectCargoSpace",
      callBack: getCargoSpace
    };
    $.modal.openOptions(options);
  }

  //关闭物资框
  function getCargoSpace(index, layero) {
    var row = layero.find("iframe")[0].contentWindow.getSelections();
    if (row.length == 0) {
      $.modal.alertWarning("请至少选择一条记录");
      $.modal.close(index);
      $.modal.closeLoading();
      return;
    }
    $("#cargoSpaceId").val(row[0].cargo_space_id);
    $("#cargoSpaceName").val(row[0].cargo_space_name);
    $.modal.close(index);
    $.modal.closeLoading();
  }

  //选择物料
  function selectProductId() {
    var options = {
      title: '选择物料',
      url : "/bas/product/selectProduct",
      callBack: getProduct
    };
    $.modal.openOptions(options);
  }

  //关闭物资框
  function getProduct(index, layero) {
    var row = layero.find("iframe")[0].contentWindow.getSelections();
    if (row.length == 0) {
      $.modal.alertWarning("请至少选择一条记录");
      $.modal.close(index);
      $.modal.closeLoading();
      return;
    }
    $("#density").val(row[0].productDensity);
    $("#diam").val(row[0].productDiam);
    // $("#weight").val(row[0].cargoSpaceName);
    $("#orderLevel").val(row[0].productLength);
    $("#singleWeight").val(row[0].sigleWeight);
    $("#productId").val(row[0].productId);
    $("#productName").val(row[0].productName);
    $.modal.close(index);
    $.modal.closeLoading();
  }
</script>
</body>
</html>